<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
 <input type="hidden" name="organizations/organization[0]/sequence_no" value="1" >
<input type="hidden" name="organizations/organization[0]@submit_org" value="1" >
<input type="hidden" name="organizations/organization[0]/org_code" value="<x:out select="$xmlData/data/organizations/organization[@submit_org=1]/org_code"/>" >







<div class="t_bar">
	<span class="color_red">*</span>申请项目
</div>


<div id = "div10" style="display:none">
<!-- 下表为《实验动物生产许可证申请书》填写内容 -->
	<table  id="tblMileStones1" cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
			<thead >
					<tr style="border:1px solid #B7D1E6">
						<th class="TblHead" align="center"  width="5%">选择</th>
						<th class="TblHead" align="center"  width="5%">序号</th>
						<th class="TblHead" align="center"  width="15%">动物品种、品系</th>
						<th class="TblHead" align="center"  width="15%">动物等级</th>
						<th class="TblHead" align="center"  width="15%">设施地址</th> 
						<th class="TblHead" align="center"  width="10%">设施面积</th> 
						<th class="TblHead" align="center"  width="10%">动物来源</th> 
						<th class="TblHead" align="center"  width="10%">引种数量</th> 
						<th class="TblHead" align="center"  width="15%">引种时间</th> 
					</tr>
			</thead>
			<tbody id="tab">
					<tr style="display:none">
						<td align="center">
							<input type="radio" class="radiobutton" name="selMileStones1" >
						</td>
						
						<td align="center">
							<span name="milestones1|milestone[0]@seq_no" >[index]</span> 
						</td>
						
						<td align="center">
						  <input type="text"  id="content1[0]" name="milestones1|milestone[0]|content1" label="动物品种、品系"  maxlength="10"  onchange="synchron(this)"
						         class="required input_text"  value=""  style="width:80%"/>
						</td>
						
						<td align="center">
						  <input type="text"  id="content2[0]" name="milestones1|milestone[0]|content2" label="动物等级"  maxlength="10"
						         class="required input_text"  value=""  style="width:80%"/>
						</td>
						
						<td align="center">
						  <input type="text"  id="content3[0]" name="milestones1|milestone[0]|content3" label="设施地址"  maxlength="10"
						         class="required input_text"  value=""  style="width:80%"/>
						</td>
						
						<td align="center">
						  <input type="text"  id="content4[0]" name="milestones1|milestone[0]|content4" label="设施面积"  maxlength="10"
						         class="required input_text"  value=""  style="width:80%"/>
						</td>
						
						<td align="center">
						  <input type="text"  id="content5[0]" name="milestones1|milestone[0]|content5" label="动物来源"  maxlength="10"
						         class="required input_text"  value=""  style="width:80%"/>
						</td>
						
						<td align="center">
						  <input type="text"  id="content6[0]" name="milestones1|milestone[0]|content6" label="引种数量"  maxlength="5"
						         class="required input_text"  value=""  style="width:80%"/>
						</td>
						
						<td align="center">
							<input  id="milestone_date_[0]" name="milestones1|milestone[0]|date" value="" class=" required input_text date" style="width:70px" label="引种时间" />
						</td>
						
					</tr>
					
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/milestones1/milestone" var="milestone">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr>
						<td align="center">
							<input type="radio" class="radiobutton" name="selMileStones1" >
						</td>
						
						<td align="center">
							<span   name="milestones1/milestone[${flag}${index}]@seq_no" ><x:out select="$milestone/@seq_no"/></span> 
						</td>
						
						<td align="center">
						    <input type="text"  id="content1[${flag}${index}]" name="milestones1/milestone[${flag}${index}]/content1" label="动物品种、品系"  maxlength="10"  onchange="synchron(this)"
						           value="<x:out select="$milestone/content1"/>"   style="width:80%"   class="required input_text"/>
						</td>
						                          
						 <td align="center">
						    <input type="text"  id="content2[${flag}${index}]" name="milestones1/milestone[${flag}${index}]/content2" label="动物等级"  maxlength="10" 
						           value="<x:out select="$milestone/content2"/>"   style="width:80%"   class="required input_text"/>
						</td>   
						
						<td align="center">
						    <input type="text"  id="content3[${flag}${index}]" name="milestones1/milestone[${flag}${index}]/content3" label="设施地址"  maxlength="10" 
						           value="<x:out select="$milestone/content3"/>"   style="width:80%"   class="required input_text"/>
						</td>
						
						<td align="center">
						    <input type="text"  id="content4[${flag}${index}]" name="milestones1/milestone[${flag}${index}]/content4" label="设施面积"  maxlength="10" 
						           value="<x:out select="$milestone/content4"/>"   style="width:80%"   class="required input_text"/>
						</td>
						
						<td align="center">
						    <input type="text"  id="content5[${flag}${index}]" name="milestones1/milestone[${flag}${index}]/content5" label="动物来源"  maxlength="10" 
						           value="<x:out select="$milestone/content5"/>"   style="width:80%"   class="required input_text"/>
						</td>
						
						<td align="center">
						    <input type="text"  id="content6[${flag}${index}]" name="milestones1/milestone[${flag}${index}]/content6" label="引种数量"  maxlength="5" 
						           value="<x:out select="$milestone/content6"/>"   style="width:80%"   class="required input_text"/>
						</td>                      
						                                 
						<td align="center">
							<c:set var="date" scope="page"><x:out select="$milestone/date"/></c:set>
							<input  id="milestone_date_[${flag}${index}]" value="${date}" label="引种日期" name="milestones1/milestone[${flag}${index}]/date" class="required date input_text"  style="width:70px" label="引种时间" /> 
						</td>

					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					</x:forEach>
					<script type="text/javascript">
						showAllDateTag("tblMileStones1");
					</script>
				</tbody>
					</table>
					<br/>

	<table width="98%" align="center">
					<tr ><td>
					<input class="button" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('tblMileStones1',20,'申请项目表最多只能填写20条')){addNewRow1('tblMileStones1','','','tblMileStones3');showDateTag('tblMileStones1');showAllDateTag('tblMileStones3');}try{top.resizeFrame();}catch(e){};">
					<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev1('tblMileStones1','selMileStones1','tblMileStones3')">
					<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext1('tblMileStones1','selMileStones1','tblMileStones3')">
					<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow1('tblMileStones1','申请项目表','','','','tblMileStones3')">
					</td></tr>
	</table>
</div>	


<script type="text/javascript">

function synchron(obj){
//同步数据到第二张表
    var index= $(obj).parents("tr").find("td:eq(1) span[name$='seq_no']").text();
    var content = $(obj).val();
    //alert(content);
    //alert($("#tblMileStones3 tbody").find("tr:eq("+(index)+")").find("td:eq(1) input[name$='content1']").html());
    $("#tblMileStones3 tbody").find("tr:eq("+(index)+")").find("td:eq(1) input[name$='content1']").val(content);
}




//添加一行
function addNewRow1(tableId,url,title,tableIdOther)
{
	if(url!=null&&url!=""){
		showThickBox(url,title);
		
	}//跳转页面
	else
		addNewRowDeal1($("#"+tableId),$("#"+tableIdOther));
}


function addNewRowDeal1(table,tableOther)
{
	//本表的添加行
	var maxLinNum=table.find("tr").length-2;;//获得行数，减去表头和隐藏行
	var lineNum=""+(maxLinNum+1);
	
	var addHtml=table.find("tr")[1].innerHTML;//获得隐藏行的html,查找第二行
	addHtml=addHtml.replace(/\[index\]/g,lineNum);
	lineNum = (parseInt(lineNum, 10)-1).toString();//2011.12.13 行下标比行号小1(隐藏行下标[0]，第一行下标[00])
	if (lineNum.length==1)//如果是个位数，前面补0
		lineNum="0"+lineNum;
	addHtml=addHtml.replace(/\[0\]/g,"["+lineNum+"]");//替换html中行号
	addHtml=addHtml.replace(/\|/g,"/");//替换html中节点/的代替符"|"
	table.append("<tr>"+addHtml+"</tr>");//将html增加到最后
	
	
	//当第一张表添加行时,第二张表也要添加行
	var maxLinNum=tableOther.find("tr").length-2;;//获得行数，减去表头和隐藏行
	var lineNum=""+(maxLinNum+1);
	
	var addHtml=tableOther.find("tr")[1].innerHTML;//获得隐藏行的html,查找第二行
	addHtml=addHtml.replace(/\[index\]/g,lineNum);
	lineNum = (parseInt(lineNum, 10)-1).toString();//2011.12.13 行下标比行号小1(隐藏行下标[0]，第一行下标[00])
	if (lineNum.length==1)//如果是个位数，前面补0
		lineNum="0"+lineNum;
	addHtml=addHtml.replace(/\[0\]/g,"["+lineNum+"]");//替换html中行号
	addHtml=addHtml.replace(/\|/g,"/");//替换html中节点/的代替符"|"
	tableOther.append("<tr>"+addHtml+"</tr>");//将html增加到最后
}


//上移行

function movePrev1(tblId,selName,tableIdOther) {
	
	//本表的上移行
	if (!selName)
		selName = "";
	//没有选中
	if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
		scmWarn(irisNotes.prevWarn);
		return false;
	}
	if ($("#" + tblId + " tr").length <= 2)
		return false;
	var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
			.parents("tr").first();// 取得被选中的行
	var trPrev = trChecked.prev();// 取得上一行
	var index = trChecked.get(0).rowIndex;// 获得行号
	if (index <= 2) {// 如果是第一行
		scmWarn(irisNotes.tabelMoveWarn1);
		return false;
	}
	//trChecked.remove();
	trPrev.before(trChecked);
	trChecked.find(":radio[name*='" + selName + "']").attr("checked", 'true');
	refreshRowINdex(tblId);
	
	//另外一张表的上移行
	//alert(index);
	
	var trChecked1 = $("#" + tableIdOther + " tbody" + " tr:eq("+(index-1)+")");
	
	//alert($("#" + tableIdOther + " tbody").find("tr:eq("+(index)+")").html());
	
	var trPrev1 = trChecked1.prev();
	trPrev1.before(trChecked1);
	refreshRowINdex(tableIdOther);
}



//下移行
function moveNext1(tblId,selName,tableIdOther) {
	if (!selName)
		selName = "";
	if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
		scmWarn(irisNotes.nextWarn);
		return false;
	}
	if ($("#" + tblId + " tr").length <= 2) {
		return false;
	}
	var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
			.parents("tr").first();// 取得被选中的行
	var trNext = trChecked.next();
	var index = trChecked.get(0).rowIndex;// 获得行号
	if (index == $("#" + tblId + " tr").length - 1) {// 如果是第一行
		scmWarn(irisNotes.tabelMoveWarn2);
		return false;
	}
	//trChecked.remove();
	trNext.after(trChecked);
	trChecked.find(":radio[name*='" + selName + "']").attr("checked", "true");
	refreshRowINdex(tblId);
	
	//另外一张表的下移行
	var trChecked1 = $("#" + tableIdOther + " tbody" + " tr:eq("+(index-1)+")");
	
	//alert(trChecked1.html());
	
	var trNext1 = trChecked1.next();
	trNext1.after(trChecked1);
	refreshRowINdex(tableIdOther);
}


//删除行
  function deleteSelectedRow1(tableId,message,nummin,warnMsg,selName,tableIdOther){
//本表删除行	
	
	  if(!selName)selName="";
		var tr=$("#"+tableId+" :radio[name*='"+selName+"']:checked").parents("tr");
		if(nummin==null)
			nummin=0;
		var length=tr.length;
		if(tr.length==0)
			tr=$("#"+tableId+" tr").filter(":last");
		else if(tr.length>1)
			tr=tr.first();

		if(tr.get(0).rowIndex-1==nummin){
			scmWarn(irisNotes.delWarn1);
			return false;
		}
		if(length==0){
			
				scmWarn(irisNotes.delWarn2);
			
			return false;
		}
		  if(!confirm(messageTip.deleteTip+message+"？"))
			  return false;
		  //获取被删除行的seq_no,在另一张表中依据seq_no找到相应的行
		  var index = $(tr).find("td:eq(1) span[name$='seq_no']").text();
		  
		  tr.remove();
		  refreshRowINdex(tableId);
	  //return true;
	  
	  
	  //另外一张表的删除行
	 //var trChecked = $("#" + tableId + " :radio[name*='" + selName + "']:checked").parents("tr");//得到选取行的对象
	 
	 //alert(trChecked.html());
	 
	//var index= $(obj).parents("tr").find("td:eq(1) span[name$='seq_no']").text();
	 
	 //var index = trChecked.find("td:eq(0) span[name$='seq_no']").text();//得到选取行的行号
	 
	 //alert(index);
	 index = Number(index) + 1;
	 var trChecked1 = $("#" + tableIdOther + " tr:eq("+ (index) +")");//依据被删除行的seq_no在另一张表中找到该行
	 //alert(trChecked1.html());
	 trChecked1.remove();//删除该行
	 refreshRowINdex(tableIdOther);
}  



</script>
























<!-- 下表为《实验动物使用许可证申请书》填写内容 -->


<div id = "div11" style="display:none">
	<table  id="tblMileStones2" cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
			<thead >
					<tr style="border:1px solid #B7D1E6">
						<th class="TblHead" align="center"  width="5%">选择</th>
						<th class="TblHead" align="center"  width="5%">序号</th>
						<th class="TblHead" align="center"  width="40%">设施等级</th>
						<th class="TblHead" align="center"  width="35%">地址</th>
						<th class="TblHead" align="center"  width="15%">面积</th> 
					</tr>
			</thead>
			<tbody id="tab">
					<tr style="display:none">
						<td align="center">
							<input type="radio" class="radiobutton" name="selMileStones2" >
						</td>
						
						<td align="center">
							<span name="milestones2|milestone[0]@seq_no" >[index]</span> 
						</td>
						
						<td align="center">
						       <cpt:select id="facility_grade[index]" name="facility_grade"  key="facility_grade" onChange="initControlValue(this.id)"  style="width:90%" ></cpt:select>
				           <input type="hidden" name="milestones2|milestone[0]|facility_grade_value" value="" class="required"  lable="设施等级"/>
				           <input type="hidden" name="milestones2|milestone[0]|facility_grade_name" value="" />
			      </td>
			       
						<td align="center">
						  <input type="text"  id="content2[0]" name="milestones2|milestone[0]|content2" label="地址"  maxlength="20"
						         class="required input_text"  value=""  style="width:80%"/>
						</td>
						
						<td align="center">
						  <input type="text"  id="content3[0]" name="milestones2|milestone[0]|content3" label="面积"  maxlength="10"
						         class="required input_text"  value=""  style="width:80%"/>
						</td>

					</tr>
					
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/milestones2/milestone" var="milestone">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr>
						<td align="center">
							<input type="radio" class="radiobutton" name="selMileStones2" >
						</td>
						
						<td align="center">
							<span   name="milestones2/milestone[${flag}${index}]@seq_no" ><x:out select="$milestone/@seq_no"/></span> 
						</td>
						
						<td align="center">
			        <c:set var="facility_grade"><x:out select="$milestone/facility_grade_value" /></c:set>
			        <cpt:select id="facility_grade${index}"   name="facility_grade"   key="facility_grade" style="width: 90%;" value="${facility_grade}" onChange="initControlValue(this.id);"></cpt:select>
		        	<input type="hidden" name="milestones2/milestone[${flag}${index}]/facility_grade_value"  class="required" value="<x:out select="$milestone/facility_grade_value" />" label="设施等级"/>
			        <input type="hidden" name="milestones2/milestone[${flag}${index}]/facility_grade_name" value="<x:out select="$milestone/facility_grade_name" />"  label="设施等级"/>
		        </td>
						                     
						<td align="center">
						    <input type="text"  id="content2[${flag}${index}]" name="milestones2/milestone[${flag}${index}]/content2" label="地址"  maxlength="20" 
						           value="<x:out select="$milestone/content2"/>"   style="width:80%"   class="required input_text"/>
						</td>   
						
						<td align="center">
						    <input type="text"  id="content3[${flag}${index}]" name="milestones2/milestone[${flag}${index}]/content3" label="面积"  maxlength="10" 
						           value="<x:out select="$milestone/content3"/>"   style="width:80%"   class="required input_text"/>
						</td>
						

					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					</x:forEach>
					<script type="text/javascript">
						showAllDateTag("tblMileStones2");
					</script>
				</tbody>
					</table>
					<br/>

	<table width="98%" align="center">
					<tr ><td>
					<input class="button" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('tblMileStones2',10,'申请项目表最多只能填写10条')){addNewRow('tblMileStones2');showDateTag('tblMileStones2');}try{top.resizeFrame();}catch(e){};">
					<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev('tblMileStones2','selMileStones2')">
					<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext('tblMileStones2','selMileStones2')">
					<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('tblMileStones2','申请项目表')">
					</td></tr>
	</table>

</div>

<br/>